package validate

import (
	"goHelpers/app/entity"
	myErr "goHelpers/app/error"
	errMsg "goHelpers/app/error/user"
)

// User 验证用户
func User(v *entity.User) myErr.Error {
	// 加载错误
	err := myErr.NewError("user")

	// 验证
	if len(v.Username) == 0 {
		// 设置错误
		err.SetCodeMsg(errMsg.UserNameErr)
		return err
	}
	if len(v.Password) == 0 {
		// 设置错误
		err.SetCodeMsg(errMsg.PasswordErr)
		return err
	}
	return nil
}
